package com.quanyan.place.service;



import com.quanyan.api.APIResponse;
import com.quanyan.common.Plugin.PageObj;
import com.quanyan.place.entity.*;
import com.quanyan.place.entity.apiresp.RespPlaceInfo;
import com.quanyan.place.entity.vo.*;

import java.util.Date;
import java.util.List;
import java.util.Map;


/**
 * 场馆内部处理Service
 * Created by yangyun on 2016/4/19.
 */
public interface PlaceInnerService {

    String getCommonDataCache(String key);

    APIResponse getPlaceCommonData();

    APIResponse getFieldScales();

    APIResponse getPlaceUnitData(int placeId,int placeUnitId);

    APIResponse getPlaceData(int placeId);

    APIResponse getPlaceDetailData(int placeId);

    APIResponse importPlaceUnitData(Integer placeId, List<TbBizPlaceUnitVo> placeUnitVoList);

    APIResponse updatePlaceData(PlaceFromDataVo placeFromDataVo);

    APIResponse updatePlaceUnitData(TbBizPlaceUnitVo tbBizPlaceUnitVo);

    APIResponse importPlaceData(PlaceFromDataVo placeFromDataVo);

    PageObj<List<TbSupplier>> getSupplierData(ReqSupplierSearchVo reqSupplierSearchVo);

    APIResponse getProvinceData();

    APIResponse getCityData(Integer provinceId,boolean isEnabled);

    APIResponse getCityData(Integer cityId);

    APIResponse getDistrictData(int cityId);

    APIResponse getPlaceUnitDetailData(int placeUnitId) throws Exception;

    /**
     * 场馆数据检查
     * @param placeFromDataVo
     * @return
     */
    APIResponse validatePlaceData(PlaceFromDataVo placeFromDataVo);

    /**
     * 场馆场地数据检查
     * @param placeUnitVos
     * @return
     */
    APIResponse validatePlaceUnitData(List<TbBizPlaceUnitVo> placeUnitVos);

    /**
     * 删除场馆
     * @param placeId
     * @return
     */
    APIResponse deletePlace(Integer placeId);

    /**
     * 删除场地
     * @param placeUnitId
     * @return
     */
    APIResponse deletePlaceUnit(Integer placeUnitId);

    TbBizPlace savePlaceInfo(PlaceFromDataVo placeFromDataVo);

    PageObj<List<PlaceNewInfo>> getPlaceList(ReqPlaceSearch placeSearch);

    PlaceDistribution getPlaceDistribuctionGroup(Integer cityId, Integer category, Integer districtId, Integer primeType, Integer isSign);

    //PlaceKpiInfo getPlaceSignAndSaleRate(Integer placeId, Integer unitId, Date startDate, Date endDate);

    /**
     * 场馆签约状况明细数据取得
     * @param placeId
     * @return
     */
    PlaceKpiInfo getPlaceSignDetailData(Integer placeId);

    /**
     * 场馆销售列表数据
     * @param cityId
     * @param category
     * @param districtId
     * @return
     */
    PlaceSaleDistribution getPlaceSaleDistribuctionGroup(Integer cityId, Integer category, Integer districtId);

    /**
     *
     * @param placeId
     * @param categoryId
     * @return
     */
    List<PlaceUnitSalePlanVo> getPlaceUnitSalePlanVoGroupByUnit(Integer placeId, Byte categoryId);

    /**
     * 从数据库查询销售计划模板
     * @param placeId
     * @return
     */
    List<TbBizPlaceUnitSalePlanMain> getPlaceSalePlanTemplate(Integer placeId,Byte categoryId, Integer weekDay, Byte unitType);

    /**
     * 获取指定场馆指定项目的销售计划
     * @param placeId
     * @param categoryId
     * @param intervalTime
     * @return
     */
    List<PlaceUnitSalePlan>  getPlaceUnitSalePlan(Integer placeId, Byte categoryId, int intervalTime);

    List<PlaceUnitSalePlan> getPlaceCombinedUnitSalePlan(Integer placeId, Byte categoryId, int intervalTime);

    List<PlaceUnitSalePlan> getPlaceSalePlanFromDB(Integer placeId, Byte categoryId, Byte unitType);

    /**
     * 获取场馆经营范围
     * @param placeId
     * @return
     */
    PlaceCategoryVo getPlaceCategory(Integer placeId);

    /**
     * 保存场地单元销售计划
     * @param placeUnitSalePlan
     * @return
     */
    List<String> saveSinglePlaceSalePlan(PlaceUnitSalePlan placeUnitSalePlan, int period, Byte unitType);

    List<String> savePlaceSalePlanBatch(List<PlaceUnitSalePlan> salePlanList, int period, Byte unitType);

    /**
     * 获取场馆下场地单元营业时间
     * @param placeId
     * @return
     */
    List<TbBizPlaceUnitTime> getPlaceUnitTimeList(Integer placeId);

    /**
     * 查询合同明细
     * @param placeId
     * @param isEffective
     * @return
     */
    List<TbBizPlaceBuyContractDetail> getPlaceContractDetail(Integer placeId, boolean isEffective);

    /**
     * 场馆销售计划同步
     * @param placeId    场馆Id
     * @param periodWeek 同步周期数
     */
    void copySalePlanFromModel(Integer placeId, Integer periodWeek);



    PageObj<List<TbBizPlace>> getPlacesRistorRecord(ReqPlaceSearch reqPlaceSearch);

  

    /**
     * 保存运营规则
     * @param placeOperationRuleVo
     */
    boolean savePlaceOperationRule(PlaceOperationRuleVo placeOperationRuleVo);

    PlaceOperationRuleVo getPlaceOperationRule(Integer placeId);

    List<TbBizPlaceAuthUser> getAuthPlaceForUser(Integer id);

    /**
     * 更新场馆最低价格
     * @param placeUnitSalePlan
     * @return
     */
    boolean getMinPrice(PlaceUnitSalePlan placeUnitSalePlan);


    List<String> lockPlace(TbBizPlace placeId, TbAdminUser user);

    List<String> unlockPlace(TbBizPlace placeId, TbAdminUser user);

    List<TbBizPlace> getPlaceInfoByName(String value,TbBizPlace place);

    int countCommercePlace(Integer uid, String keywords);

    List<TbBizPlace> getCommercePlaceList(Integer uid, Integer pageNum, Integer pageSize, String keywords);

    void updateStatus();

    List<RespPlaceInfo> getCanSalePlace(Integer pageNum, Integer pageSize);

    void insertSalePlanBatch(List<TbBizPlaceUnitSalePlan> salePlanList);

    PageObj<List<TbBizPlaceUnit>> getAllPlaceUnitList(ReqPlaceUnitSearch reqPlaceUnitSearch);

    TbCity getCityDataById(Integer cityId);

    /**
     * 更新群组名称
    */
    Integer updatePlaceGroupId(MqPlaceGroupId mqPlaceGroupId);

    List<TbBizPlace> getPlaceListForSolrIndex(Map map);

    /**
     * 判断是否存在该场馆的销售计划，不存在删场馆索引
     */
    void isExsit(Integer placeId) ;

    void updatePlaceImageAndVideo(PlaceFromDataVo placeFromDataVo, Integer placeId);

    List<TbBizPlace> getPlaceList(Map map);

    /**
     * 判断是否存在指定场馆指定日期的销售计划
     * @param placeId
     * @param appointedDate
     * @return
     */
    boolean existsSalePlan(Integer placeId, Date appointedDate);

    boolean checkSalePlanNum(Integer placeId, Date appointedDate, int salePlanTemplateNum);

    /**
     * 查询指定场馆指定日期销售计划个数
     * @param placeId
     * @param appointedDate
     * @return
     */
    int countSalePlanNum(Integer placeId, Date appointedDate);

     PageObj<List<RespPlaceInfo>> getPlaceListByCategoryId(ReqPlaceSearch reqVo);


    void addPlaceIndex(TbBizPlace tbBizPlace, List<String> ids);

    void updateSalePlanToInvalidate(Integer placeId, Byte entityType);

    void updateSalePlanToInvalidateByCategroyId(Integer placeId, Integer categoryId);

    void updateSalePlanMainToInvalidate(Integer placeId, Integer categoryId);

    List<TbBizPlaceUnitSalePlan> getPlaceUnitSalePlanBySaleId(List saleidList);

    void delInvalidSalePlan(Integer placeId);

    List<TbBizPlace> getPlaceBySupplierId(Integer supplierId);

    /**
     * 根据场馆id和placeUnitIds删除时段设置
     * @param placeId
     * @param placeUnitIds
     */
    void deletePlaceUnitTime(Integer placeId, List<Integer> placeUnitIds);

    /**
     * 拆分已经预定出去的场地（时段售卖由整点售卖变为半点售卖时）
     * @param placeId
     * @param categoryId
     */
    void splitSalePlanAlreadyBooked(Integer placeId, Integer categoryId) throws Exception;

    /**
     * 删除指定场馆、指定日期的销售计划
     * @param placeId
     * @param date
     */
    void deleteSalePlanByPlaceAndDate(Integer placeId, Date date);

    /**
     * 根据销售ID 获取销售计划
     * @param saleId
     * @return
     */
    TbBizPlaceUnitSalePlan selectUnitSalePlanBySaleId(String saleId);



    void syncSalePlanPriceForRefundOrder(String placeOrderId);

    TbBizPlaceUnitSalePlanMain getPlaceSalePlanByTemplateId(Integer salePlanMainId);

    void updatePlaceUnitSalePlanBykey(TbBizPlaceUnitSalePlan salePlan);
}
